package com.hanscan.persistence.controllers;

import com.hanscan.persistence.EntityManagerSingleton;
import com.hanscan.persistence.entities.UserType;
import javax.persistence.EntityManager;
import javax.persistence.Query;

public class UserTypeJpaController
{

    public UserTypeJpaController()
    {
    }

    public EntityManager getEntityManager()
    {
        return EntityManagerSingleton.getInstance();
    }

    public UserType findUserTypeById(int id)
    {
        EntityManager em = getEntityManager();
        try
        {
            Query query = em.createNamedQuery("findUserTypeById");
            query.setParameter(1, id);
            UserType userType = (UserType) query.getSingleResult();
            return userType;
        }  
        catch (Exception ex)
        {
            ex.printStackTrace();
            return null;
        }
    }
}
